import { messages } from 'share/common';
import { Badge, Radio, Select, Checkbox, Popover, Icon, Button, Alert } from 'antd';
import React from 'react';
import components from './components';
import invoiceManagementService from 'containers/supplier-management/invoice-management/invoice-management.service';
import priceTaxRuleService from 'containers/supplier-management/price-tax-seperation-rule/price-tax-seperation-service';
import table1Img from 'images/request-and-expense-settings/invoice-management/table-1.jpg';
import table2Img from 'images/request-and-expense-settings/invoice-management/table-2.jpg';
import Info from "components/info";

const Option = Select.Option;

// info
const info1 = {
  attributes: [
    { title: messages('expense-3.key1')/*功能概述*/, dataIndex: 'function', span: 24, widthFix: false,
      render: value =>
        <span>
          {value}
          {messages('expense-3.key2')/*（注：若法人名称变更过版本，则取发票抬头与开票日期所在的法人版本范围的抬头做校验。特别地，未来法人版本生效日前，以未来法人与当前生效法人作为购买方抬头开具的发票，均不会标记“抬头有误”*/}
          <Popover autoAdjustOverflow content={<span>{messages('expense-3.key3')/*例子：*/}<img src={table1Img} style={{width: 468, height: 'auto'}}/></span>}>
            <Icon type="info-circle-o" style={{ marginRight: '10px' }}/>
          </Popover>
          {'）'}
        </span>
    },
    { title: messages('expense-3.key4')/*说明*/, dataIndex: 'explain', span: 24, widthFix: false }
  ],
  dataSource: {
    function: messages('expense-3.key5')/*开启后，校验发票的购买方信息是否在指定的校验范围内存在，不存在的发票及关联费用会被打上“抬头有误”标签。*/ ,
    explain: messages('expense-3.key6')/*【抬头&税号】发票的“购买方抬头”与“纳税人识别号”任意有值则会校验，两者均为空则不校验。（对于区块链发票，若购买方纳税人名称与购买方纳税人识别号存在任意为空，则不做抬头校验）*/
  }
};

const info2 = {
  attributes: [
    { title: messages('expense-3.key1')/*功能概述*/, dataIndex: 'function', span: 24, widthFix: false,
      render: value =>
        <span>
          {value}
          {messages('expense-3.key7')/*（注：若法人名称变更过版本，则以新法人与老法人做为购买方抬头开具的发票，均不会标记“抬头不一致”*/}
          <Popover autoAdjustOverflow content={<span>{messages('expense-3.key3')/*例子：*/}<img src={table2Img} style={{width: 468, height: 'auto'}} /></span>}>
            <Icon type="info-circle-o" style={{ marginRight: '10px' }}/>
          </Popover>
          {'）'}
        </span>
    },
    { title: messages('expense-3.key4')/*说明*/, dataIndex: 'explain', span: 24, widthFix: false }
  ],
  dataSource: {
    function: messages('expense-3.key8')/*开启后，若发票“购买方抬头”不等于关联的费用所在的报销单的【公司】的法人名称，报销单、费用、发票会被打上“抬头不一致”标签。*/,
    explain: messages('expense-3.key9')/*【抬头&税号】发票的“购买方抬头”与“纳税人识别号”任意有值则会校验，两者均为空则不校验。*/
  }
};

const info3 = {
  attributes: [{ title: messages('expense-3.key1')/*功能概述*/, dataIndex: 'function', span: 24, widthFix: false }],
  dataSource: {
    function: messages('expense-3.key10')/*开启后，校验发票票面的人员所属公司与报销单公司是否一致（即：票面人员是否与报销单公司存在合法雇工关系），若否则报销单、费用、发票会被打上“非雇员发票”标签。如果发票票面的人员信息在系统中匹配到多家所属公司，则报销单、费用、发票会被打上“发票所属公司不明确”的标签。*/,
  }
};

const info4 = {
  attributes: [
    { title: messages('expense-3.key1')/*功能概述*/, dataIndex: 'function', span: 24, widthFix: false },
    { title: messages('expense-3.key4')/*说明*/, dataIndex: 'explain', span: 24, widthFix: false }
  ],
  dataSource: {
    function: messages('expense-3.key11')/*启用后，发票代码相同的多张发票，若发票号码之间差额的绝对值大于小于设定的“连号绝对值”，发票和所在费用会被打上“发票连号”标签。*/,
    explain: messages('expense-3.key12')/*“发票代码+发票号码” 值均不为空的发票才做连号校验。*/
  }
};

const info5 = {
  attributes: info4.attributes,
  dataSource: {
    function: messages('expense-3.key13')/*设置逾期校验和提醒规则，命中下述规则的发票，会在发票和关联费用上显示“发票逾期”标签。*/,
    explain: messages('expense-3.key14')/*一张发票同时命中多条（同一层级的）逾期规则，逾期时间早的规则优先级高。*/
  }
};

const info6Pop = <section>
  <strong>{messages('expense-3.key15')/*保险费发票*/}</strong>
  <div>{messages('expense-3.key16')/*商品服务名称包含“保险服务”的发票*/}</div>
  <strong>{messages('expense-3.key17')/*通讯费发票*/}</strong>
  <div>{messages('expense-3.key18')/*销售方名称为“中国移动通信集团”或“中国联合网络通信有限公司”“中国电信股份有限公司”， 或者商品服务名称包含“通信服务”或“电信服务”或“通信业务服务费”或“\n    *电信服务*通信服务费”的发票*/}
  </div>
  <div>{messages('expense-3.key19')/*注：购方名称开具“个人”二字的，不属于此范围*/}</div>
</section>;

const info6 = {
  attributes: info4.attributes,
  dataSource: {
    function: <span>{messages('expense-3.key20')/*启用后，校验发票归属人与发票关联的费用归属人是否一致，若否，则该费用和发票会被打上“他人发票”标签。校验的发票范围为火车票、机票行程单、客运发票、购买方抬头名称为开具某个人姓名的通讯费发票和保险费发票*/} <Popover placement="topLeft" trigger="click" content={info6Pop}><Icon type="info-circle" className='default-color-font'/></Popover></span>,
    explain: <span> {messages('expense-3.key21')/*1. 费用归属人取值逻辑：优先取员工信息中“身份证”的“姓”+“名”，若身份证的姓名为空，则取员工信息的姓名*/} <br/>  {messages('expense-3.key22')/*2. 发票归属人为空时不校验。火车票、机票行程单和客运发票的发票归属人取“归属人”字段；抬头名称为开具某个人姓名的通讯费发票和保险费发票的发票归属人取“购买方抬头名称”*/}</span>
  }
};

const info7 = {
  attributes: info4.attributes,
  dataSource: {
    function: messages('expense-3.key23')/*启用后，发票保存时，会校验汇联易系统是否已存在同发票类型且代码+号码与此相同的发票，若有，则该发票与所在费用、重复发票与其所在费用均会被打上“重复发票”标签。*/,
    explain: messages('expense-3.key24')/*发票代码、发票号码任意为空则不进行重复校验（特别地：机票行程单只有发票号码，只取发票号码进行重复校验）*/
  }
};

const handleJump = () => {
  window.open('/main/finance-setting/tax-code');
};

const renderFunction8 = () => {
const messageArr = [
  messages('expense-3.key25')/*启用后，系统会根据启用状态的费用类型和发票映射规则，校验发票和费用关联关系是否与规则相匹配。*/,
  messages('expense-3.key26')/*1.若规则管控力度为弱管控，不匹配则在费用和发票上打上“发票不匹配”标签。*/,
  messages('expense-3.key27')/*2.若规则管控力度为强管控，不匹配则分下述两种场景：*/,
  messages('expense-3.key28')/*（1）发票生成费用，系统会根据启用状态的费用类型和发票映射规则控制发票可生成的费用类型范围，规则以外的费用类型不显示；*/,
  messages('expense-3.key29')/*（2）先创建费用再归集发票，系统会校验发票和费用关联关系是否与规则相匹配，不匹配则在费用和发票上打上“发票不匹配”标签，含此标签的费用不允许保存成功。*/,
  messages('expense-3.key30')/*（系统默认允许“发票不匹配”生成费用）*/,
]
  return messageArr.map(item => <span> {item} <br/> </span>);
};

const renderExplain8 = () => {
  return (
      <span>
        <span>{messages('expense-3.key31')/*此校验生效的前提是存在启用状态的发票&费用映射规则，您可以跳转至*/}</span>
        <Button ghost type="link" onClick={handleJump}>
          <span>{messages('expense-3.key32')/*【财务管理-单据审核设置-费用类型和发票映射关系】*/}</span>
        </Button>
        <span>{messages('expense-3.key33')/*页面设置规则及规则管控力度*/}</span>
      </span>
  );
};

const info8 = {
  attributes: info4.attributes,
  dataSource: {
    function: renderFunction8(),
    explain: renderExplain8()
  }
};

const info9 = {
  attributes: [{ title: messages('expense-3.key34')/*设置说明*/, dataIndex: 'explain', span: 24 }],
  dataSource: {
    explain: messages('expense-3.key35')/*启用下述校验，与功能描述不符的发票将会被打上“发票不合规”标签，并提示对应的不合规原因。不满足前置条件的发票则不校验。*/
  }
};

// 业务枚举值
const validates = [
  { name: messages('expense-3.key36')/*开启*/, value: true },
  { name: messages('expense-3.key37')/*关闭*/, value: false }
];

const titleValidates = [
  { name: messages('expense-3.key38')/*抬头&税号*/, value: 'Y' },
  { name: messages('expense-3.key39')/*抬头&税号&地址电话&开户行账号*/, value: 'FULL_CHECK' }
];

const titleValidateRange = [
  { name: messages('expense-3.key249')/*(仅第一主岗) 公司*/, value: 'COMPANY' },
  { name: messages('expense-3.key250')/*(岗位所在) 公司*/, value: 'COMPANY_POSITION' },
  { name: messages('expense-3.key41')/*账套*/, value: 'SET_OF_BOOK' },
  { name: messages('expense-3.key42')/*租户*/, value: 'TENANT' }
];

const noInvoiceTitleValidates = [
  {
    name: messages('expense-3.key17')/*通讯费发票*/,
    value: 'COMMUNICATION',
    desc: messages('expense-3.key43')/*销售方名称为“中国移动通信集团”或“中国联合网络通信有限公司”“中国电信股份有限公司”，或者商品服务名称包含“通信服务”或“电信服务”或“通信业务服务费”或“ *电信服务*通信服务费”的发票*/
  },
  {
    name: messages('expense-3.key15')/*保险费发票*/,
    value: 'INSURANCE',
    desc: messages('expense-3.key16')/*商品服务名称包含“保险服务”的发票*/
  },
];

const consecutiveCheckRange = [
  { name: messages('expense-3.key44')/*同公司*/, value: 'COMPANY' },
  { name: messages('expense-3.key45')/*本人*/, value: 'PERSON' },
];

const invoiceCheckMap = new Map([['Y', messages('expense-3.key46')/*开通*/], ['N', messages('expense-3.key47')/*未开通*/], [null, messages('expense-3.key48')/*此类型不查验*/]]);

const enabled = {
  component: components.get('Group'),
  name: messages('common.column.status')/*状态*/,/*状态*/
  child: validates.map(item => <Radio value={item.value}>{item.name}</Radio>),
};

// 第一层Tab
export const levelMap = new Map([
  ['invoice-check',
    {
      info: {
        dataSource: { explain: messages('expense-3.key49')/*您可在此页面设置发票校验规则（包含发票抬头校验、发票过期、发票归属人校验、发票连号校验、发票重复校验）*/ },
        attributes: [info4.attributes[1]]
      },
      columns: ['companyNameList', 'operation'],
      searchColumns: ['companyNameList'],
      formList:{}
    }
  ],
  ['invoice-to-cost',
    {
      info: {
        dataSource: {
          explain: messages('expense-3.key50')/*新建规则优先级高于默认规则，规则的优先级数字可重复，存在优先级数字重复的规则时，排序靠前的规则优先级更高。*/,
          function: messages('expense-3.key51')/*您可在此基于“发票属性”及“发票校验结果”，管控发票能否生成费用，限定可生成的费用类型范围。*/
        },
        attributes: info4.attributes
      },
      columns: ['priority', 'companyNameList', 'operation'],
      searchColumns: ['companyNameList'],
      formList: {
        priority: { required: true, initData: 5, params: { min: 1 } },
        'dividing1': {
          isRegex: true,
          child: <span>{messages('expense-3.key52')/*校验条件*/}</span>,
          params: { className: 'sub-title' }
        },
        duplicatedReceipt: {},
        consecutiveReceipt: {},
        invalidTitleReceipt: {},
        cancelledReceipt: {},
        trueTestCode: {},
        goodsServiceName: {},
        salesParty: {},
        'dividing2': {
          isRegex: true,
          child: <span>{messages('expense-3.key53')/*校验结果*/}</span>,
          params: { className: 'sub-title' }
        },
        canGenerateInvoice: { required: true },
        expenseTypeLimit: {}
      }
    }],
  ['invoice-controls',
    {
      info: {
        dataSource: {
          explain: messages('expense-3.key54')/*您可在此页面设置手录各个类型的发票时，显示/必填哪些字段*/,
        },
        attributes: [info4.attributes[1]]
      },
      columns: ['companyNameList', 'operation'],
      searchColumns: ['companyNameList'],
      formList:{}
    }
  ],
  ['price-tax',
    {
      info: {
        dataSource: {
          explain: messages('expense-3.key50')/*新建规则优先级高于默认规则，规则的优先级数字可重复，存在优先级数字重复的规则时，排序靠前的规则优先级更高。*/,
          function: messages('expense-3.key55')/*您可以在此配置费用是否做价税分离，规则作用于（财务角色可见）费用详情页的“能否抵扣”默认值。若无自定义规则，则关联可抵扣发票的费用默认可抵扣；未关联发票的费用、关联不可抵扣发票的费用默认不可抵扣。若存在自定义规则，则无论是否关联发票，都按照自定义规则计算费用“能否抵扣”的默认值。*/,
        },
        attributes: info4.attributes
      },
      columns: ['priority', 'companyNameList', 'operation'],
      searchColumns: ['companyNameList'],
      formList: {
        priority: { required: true, initData: 2 },
        'dividing1': {
          isRegex: true,
          child: <span>{messages('expense-3.key52')/*校验条件*/}</span>,
          params: { className: 'sub-title' }
        },
        'dividing3': {
          isRegex: true,
          child: (
            <div style={{ marginBottom: 12 }}>
              <Info
                paragraph
                attributes={[{
                  title: '', dataIndex: 'info', span: 24, widthFix: false, colon: false,
                  render: () => (
                    <div>
                      {messages('expense-3.key56')/*多个条件之间为“且”关系。*/} <br/>
                      {messages('expense-3.key57')/*校验条件为空时，表示不校验此条件；*/} <br/>
                      {messages('expense-3.key58')/*校验条件多选时，同条件的多个值为“或”关系，即命中其一则表示命中此条件。*/}
                    </div>
                  )
                }]}
                dataSource={{}}
              />
            </div>
          )
        },
        expenseTypeLimit2: {},
        invoiceLabel: {},
        businessType: {},
        reimbursementType: {},
        allReceiptTaxed:{},
        'dividing2': {
          isRegex: true,
          child: <span>{messages('expense-3.key53')/*校验结果*/}</span>,
          params: { className: 'sub-title' }
        },
        enableTax: { required: true },
        defaultTaxRate: {},
      }
    }]
]);

export const columnsMap = new Map([
  ['companyNameList',
    {
      title: messages('expense-3.key59')/*启用公司*/,
      dataIndex: 'companyNameList',
      render: value => value ? <Popover placement="topLeft" content={value.join(',')}>{value.join(',')} </Popover> : messages('expense-3.key60')/*通用*/
    }
  ],
  ['enabled',
    {
      title: messages('common.column.status')/*状态*/,
      dataIndex: 'enabled',
      render: enabled => (
        <Badge
          status={enabled ? 'success' : 'error'}
          text={enabled ? messages('expense-3.key61')/*启用temp*/ : messages('expense-3.key62')/*禁用temp*/}
        />
      )
    }
  ],
  ['operation',
    {
      title: messages('common.operation')/*操作*/,
      dataIndex: 'operation'
    }
  ],
  ['description',
    {
      title: messages('expense-3.key63')/*规则说明*/,
      dataIndex: 'description',
      render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
    }
  ],
  ['receiptTypeList',
    {
      title: messages('expense-3.key64')/*适用发票类型*/,
      dataIndex: 'receiptTypeList',
      render: value => value && value[0]
        ? <Popover placement="topLeft" content={value.map(item => item.messageKey)
          .join('，')}>{value.map(item => item.messageKey)
          .join('，')}</Popover>
        : messages('common.all')/*全部*/
    }
  ],
  ['taxCodeList',
    {
      title: messages('expense-3.key65')/*适用税收分类编码*/,
      dataIndex: 'taxCodeList',
      render: value => value && value[0]
        ? <Popover placement="topLeft" content={value.map(item => item.name)
          .join('，')}>{value.map(item => item.name)
          .join('，')}</Popover>
        : messages('common.all')/*全部*/
    }
  ],
  ['forceEnabled',
    {
      title: messages('expense-3.key66')/*管控力度*/,
      dataIndex: 'forceEnabled',
      render: value => value ? messages('expense-3.key67')/*强管控*/ : messages('expense-3.key68')/*弱管控*/
    }
  ],
  ['priority',
    {
      title: messages('expense-3.key69')/*优先级*/,
      dataIndex: 'priority'
    }
  ],
  ['receiptTypeNo',
    {
      title: messages('expense-3.key70')/*发票类型编码*/,
      dataIndex: 'receiptTypeNo',
      width: '10%'
    }
  ],
  ['receiptType',
    {
      title: messages('expense-3.key71')/*发票类型名称*/,
      dataIndex: 'receiptType'
    }
  ],
  ['invoiceCheck',
    {
      title: messages('expense-3.key72')/*法人查验开通状态*/,
      dataIndex: 'invoiceCheck',
      render: value => invoiceCheckMap.has(value) ? invoiceCheckMap.get(value) : '-',
      width: '15%'
    }
  ],
  ['fieldList',
    {
      title: messages('expense-3.key73')/*字段配置（显示字段，带*必填)*/,
      dataIndex: 'fieldList',
      render: value => value && value[0]
        ? <Popover placement="topLeft" content={value.filter(item => item.value !== '10').map(item => item.fieldLabel + (item.value === '30' ? '*' : ''))
          .join('，')}>{value.filter(item => item.value !== '10').map(item => item.fieldLabel + (item.value === '30' ? '*' : ''))
          .join('，')}</Popover>
        : messages('common.all')/*全部*/
    }
  ],
  ['operationSpecial',
    {
      title: messages('common.operation')/*操作*/,
      dataIndex: 'operationSpecial'
    }
  ],
]);

export const searchColumnsMap = new Map([['companyNameList',
  {
    id: 'companyIds',
    label: messages('expense-3.key59')/*启用公司*/,
    component: 'Chooser',
    props: {
      labelKey: 'name',
      valueKey: 'id',
      type: 'priority_company'
    },
    dataIndex: 'companyNameList',
    parser: value => ({
      companyIds: value ? value.map(item => item.id) : null
    })
  }],
  ['invoiceCheck',
    {
      component: 'Select',
      id: 'invoiceCheck',
      dataIndex: 'invoiceCheck',
      label: messages('expense-3.key72')/*法人查验开通状态*/,
      children: [
        { label: messages('expense-3.key46')/*开通*/, value: 'Y' },
        { label: messages('expense-3.key47')/*未开通*/, value: 'N' },
        { label: messages('expense-3.key48')/*此类型不查验*/, value: null }].map(item => <Option key={item.value}>{item.label}</Option>),
      tagParser: value =>  invoiceCheckMap.get(value)
    }]
]);

export const formMap = new Map([
  ['enabled',
    {
      component: components.get('Switch'),
      name: messages('common.column.status')/*状态*/,/*状态*/
    }
  ],
  ['title',
    {
      component: components.get('h1'),
      isNotForm: true,
    }
  ],
  ['header',
    {
      component: components.get('h3'),
      isNotForm: true
    }
  ],
  ['info',
    {
      component: components.get('Info'),
      isNotForm: true
    }
  ],
  ['invoiceTitleValidate', enabled],
  ['receiptTypeList',
    {
      component: components.get('Chooser'),
      name: messages('common.invoice.type')/*发票类型*/,
      params: {
        type: 'select_invoice_type_all',
        labelKey: 'name',
        valueKey: 'code',
        single: false,
        placeholder: messages('common.all')/*全部*/
      }
    }
  ],
  ['titleValidateDetail',
    {
      component: components.get('Select'),
      name: messages('expense-3.key74')/*校验内容*/,
      child: titleValidates.map(item => <Option key={item.value}>{item.name}</Option>)
    }
  ],
  ['titleValidateRange',
    {
      component: components.get('Select'),
      name: messages('expense-3.key75')/*校验范围*/,
      child: titleValidateRange.map(item => <Option key={item.value}>{item.name}</Option>)
    }
  ],
  ['expenseReportTitleValidate', enabled],
  ['noInvoiceTitleValidate',
    {
      component: components.get('CheckboxGroup'),
      name: messages('expense-3.key251')/*此类发票开具个人抬头则不做上述校验*/,
      child: noInvoiceTitleValidates.map(item => (
        <Checkbox key={item.value} value={item.value}>
          {item.name} <Popover content={item.desc}><Icon type="info-circle-o"/></Popover>
        </Checkbox>
      )),
    }
  ],
  ['checkNonEmployee', enabled],
  ['receiptConsecutiveControl', enabled],
  ['expenseTypeList',
    {
      component: components.get('Chooser'),
      name: messages('common.expense.type')/*费用类型*/,
      params: {
        type: 'select_expense_type_all',
        valueKey: 'id',
        labelKey: 'name',
        single: false,
        placeholder: messages('common.all')/*全部*/
      }
    }
  ],
  ['consecutiveAbsolute',
    {
      component: components.get('InputNumber'),
      name: messages('expense-3.key77')/*连号绝对值*/,
      params: {
        className: 'verification__input_consecutive',
        placeholder: messages('expense-3.key78')/*请输入temp2*/
      }
    }
  ],
  ['consecutiveCheck',
    {
      component: components.get('Select'),
      name: messages('expense-3.key79')/*连号发票校验范围*/,
      child: consecutiveCheckRange.map(item => <Option key={item.value}>{item.name}</Option>)
    }
  ],
  ['receiptOwnerCheck', enabled],
  ['receiptDuplicateCheck', { ...enabled, params: { disabled: true } }],
  ['overdueTable', { component: components.get('OverdueTable'), isNotForm: true }],
  ['priority',
    {
      component: components.get('InputNumber'),
      name: messages('expense-3.key69')/*优先级*/,
      params: { min: 1, step: 1 }
    }
  ],
  ['duplicatedReceipt',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key80')/*是否重复*/,
      params: { type: 'invoice-check-duplicated', entity: true }
    }
  ],
  ['consecutiveReceipt',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key81')/*是否连号*/,
      params: { type: 'invoice-check-consecutive', entity: true }
    }
  ],
  ['invalidTitleReceipt',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key82')/*是否抬头有误*/,
      params: { type: 'invoice-check-title', entity: true }
    }
  ],
  ['cancelledReceipt',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key83')/*发票状态*/,
      params: { type: 'invoice-check-status', entity: true }
    }
  ],
  ['trueTestCode',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key84')/*查验返回结果*/,
      params: { type: 'invoice-check-result', entity: true }
    }
    ],
  ['goodsServiceName', { component: components.get('Input'), name:messages('expense-3.key85')/*商品／服务名称包含*/ }],
  ['salesParty', { component: components.get('Input'), name:messages('expense-3.key86')/*销售方名称包含*/ }],
  ['canGenerateInvoice',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key87')/*是否可生成费用*/,
      params: {
        type: 'invoice-check-created',
        params: { listCode: 3006, listType: 'SYSTEM' },
        entity: true
      }
    }
  ],
  ['expenseTypeLimit',
    {
      component: components.get('Chooser'),
      name: messages('expense-3.key88')/*指定费用类型*/,
      params: {
        type: 'select_expense_type_all',
        valueKey: 'id',
        labelKey: 'name',
        single: false,
        placeholder: messages('common.all')/*全部*/
      }
    }
  ],
  ['dividing',
    {
      component: components.get('section'),
      isNotForm: true,
    }
  ],
  ['expenseTypeLimit2',
    {
      component: components.get('Chooser'),
      name: messages('common.expense.type')/*费用类型*/,
      params: {
        type: 'select_expense_type_all',
        valueKey: 'id',
        labelKey: 'name',
        single: false,
      }
    }
  ],
  ['invoiceLabel',
    {
      component: components.get('Chooser'),
      name: messages('expense-3.key89')/*费用标签包含*/,
      params: {
        type: 'select_invoice_label',
        valueKey: 'id',
        labelKey: 'name',
        single: true,
        listExtraParams: { sence: 'INVOICE_BASED_TAX_RULE' }
      }
    }
  ],
  ['businessType',
    {
      component: components.get('Chooser'),
      name: messages('expense-3.key90')/*业务用途*/,
      params: {
        type: 'select_business_type',
        valueKey: 'id',
        labelKey: 'name',
        single: true,
      }
    }
  ],
  ['reimbursementType',
    {
      component: components.get('Chooser'),
      name: messages('expense-3.key91')/*报销类型*/,
      params: {
        type: 'select_expense_type',
        valueKey: 'id',
        labelKey: 'name',
        single: true,
      }
    }
  ],
  ['enableTax',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key92')/*是否启用价税分离*/,
      params: {
        type: 'invoice-check-created',
        params: { listCode: 3014, listType: 'SYSTEM' },
        entity: true
      }
    }
  ],
  ['defaultTaxRate',
    {
      component: components.get('Chooser'),
      name: messages('expense-3.key93')/*默认税率*/,
      params: {
        type: 'select_default_tax',
        valueKey: 'id',
        labelKey: 'name',
        single: true,
      }
    }
  ],
  ['receiptExpenseMapping',{...enabled}],
  ['allReceiptTaxed',
    {
      component: components.get('Selector'),
      name: messages('expense-3.key252')/*是否关联了可抵扣发票*/,
      params: { type: 'all_invoice_price-tax', entity: true }
    }
  ],
  ['complianceRuleCard',
    {
      isNotForm: true,
      component: components.get('ComplianceRuleCard')
    }
  ],
  ['jumpConfig',
    {
      component: components.get('jumpConfig'),
      isNotForm: true,
    }]
]);

export const verificationMap = new Map([
  ['head-up-verification',
    {
      'jumpConfig': {
        params:{
          style: { marginBottom: '12px' }
        }
      },
      'header1': {
        isRegex: true,
        child: messages('expense-3.key95')/*发票可报销的抬头范围管控*/,
        params: { className: 'verification__h3' }
      },
      'info1': { isRegex: true, params: info1 },
      'invoiceTitleValidate': { initData: true },
      'receiptTypeList': {
        extra: messages('expense-3.key96')/*仅对选定范围的发票类型进行抬头有误校验*/ ,
        initData: [
          {id: '04', code: '04', name: messages('expense-3.key97')/*增值税普通发票*/},
          {id: '10', code: '10', name: messages('expense-3.key98')/*增值税普通发票(电子)*/},
          {id: '11', code: '11', name: messages('expense-3.key99')/*增值税普通发票(卷式)*/},
          {id: '01', code: '01', name: messages('expense-3.key100')/*增值税专用发票*/},
          {id: '14', code: '14', name: messages('expense-3.key101')/*增值税电子普通发票（通行费）*/}
        ]
      },
      'titleValidateDetail': { initData: 'Y' },
      'titleValidateRange': { initData: 'TENANT' },
      'header2': {
        isRegex: true,
        child: messages('expense-3.key102')/*跨公司报销管控*/,
        params: { className: 'verification__h3' }
      },
      'info2': { isRegex: true, params: info2 },
      'expenseReportTitleValidate': { initData: true },
      'noInvoiceTitleValidate': {
        extra: messages('expense-3.key253')/*上述枚举发票的购买方抬头名称常被开具为\"个人\"或具体人员姓名。勾选后，此类发票开具个人抬头则不做上述抬头校验，开具公司抬头则仍会做校验*/,
        initData: ['COMMUNICATION', 'INSURANCE']
      }
    }
  ],
  ['consecutive-verification',
    {
      'info4': { isRegex: true, params: info4 },
      'jumpConfig': {
        params:{
          style: { marginBottom: '12px' }
        }
      },
      'receiptConsecutiveControl': { initData: true },
      'expenseTypeList': {
        listExtraParams: { enabled: true, subsidyType: 0 },
        extra: messages('expense-3.key104')/*仅对选定范围的费用类型上的发票进行连号校验*/
      },
      'receiptTypeList': { extra: messages('expense-3.key105')/*仅对选定范围的发票类型进行连号校验*/ },
      'consecutiveAbsolute': {
        initData: 1,
        required: true,
        extra: messages('expense-3.key106')/*案例：下述校验范围内已存在发票A（发票代码为111，发票号码为222），再录入发票B（发票代码为111，发票号码为221）、发票C（发票代码为111，发票号码为223），那么发票A、B、C以及发票关联的费用均会标记“发票连号”*/
      },
      'consecutiveCheck': { initData: 'COMPANY' }
    }
  ],
  ['overdue-verification',
    {
      'info5': { isRegex: true, params: info5 },
      'overdueTable': { params: {} }
    }
  ],
  ['owner-verification',
    {
      'header1': {
        isRegex: true,
        child: messages('expense-3.key107')/*他人发票校验*/,
        params: { className: 'verification__h3' }
      },
      'info6': { isRegex: true, params: info6 },
      'receiptOwnerCheck': { initData: true },
      'header2': {
        isRegex: true,
        child: messages('expense-3.key108')/*雇员发票校验*/,
        params: { className: 'verification__h3' }
      },
      'info3': { isRegex: true, params: info3 },
      'checkNonEmployee': { initData: true }
    }
  ],
  ['repeat-verification',
    {
      'info7': { isRegex: true, params: info7 },
      'receiptDuplicateCheck': { initData: true }
    }
  ],
  [
    'compliance-check',
    {
      'info9': { isRegex: true, params: info9 },
      'complianceRuleCard': {  params: {} }
    }
  ],
  ['match-check',
    {
      'info8': { isRegex: true, params: info8 },
      'receiptExpenseMapping': { initData: false }
    }
  ]
]);

export const verificationGetServiceMap = new Map([
  ['head-up-verification', invoiceManagementService.getHeadUpVerification],
  ['consecutive-verification', invoiceManagementService.getConsecutiveVerification],
  ['owner-verification', invoiceManagementService.getInvoiceCheckDetails],
  ['repeat-verification', invoiceManagementService.getInvoiceCheckDetails],
  ['match-check', invoiceManagementService.getInvoiceCheckDetails],
]);

export const verificationPostServiceMap = new Map([
  ['head-up-verification', invoiceManagementService.saveHeadUpVerification],
  ['consecutive-verification', invoiceManagementService.saveConsecutiveVerification],
  ['owner-verification', invoiceManagementService.saveInvoiceCheckDetails],
  ['repeat-verification', invoiceManagementService.saveInvoiceCheckDetails],
  ['match-check', invoiceManagementService.saveInvoiceCheckDetails],
]);

export const invoiceCheckPostServiceMap = new Map([
  ['invoice-check', invoiceManagementService.newInvoiceCheck],
  ['invoice-to-cost', invoiceManagementService.newInvoiceToCost],
  ['invoice-controls', invoiceManagementService.newInvoiceControl],
  ['price-tax', priceTaxRuleService.setSeparationConfig],
]);

export const invoiceCheckGetServiceMap = new Map([
  ['invoice-check', invoiceManagementService.getInvoiceChecks],
  ['invoice-to-cost', invoiceManagementService.getInvoiceToCost],
  ['invoice-controls', invoiceManagementService.getInvoiceControl],
  ['price-tax', priceTaxRuleService.getSeparationConfig],
]);

export const invoiceCheckDeleteServiceMap = new Map([
  ['invoice-check', invoiceManagementService.deleteInvoiceCheck],
  ['invoice-to-cost', invoiceManagementService.deleteInvoiceToCost],
  ['invoice-controls', invoiceManagementService.deleteInvoiceControl],
  ['price-tax', priceTaxRuleService.deletePriceTax],
]);

export const invoiceCheckPriorityServiceMap = new Map([
  ['invoice-to-cost', invoiceManagementService.highestPriority],
  ['price-tax', priceTaxRuleService.highestPriority],
]);

// 现在的通用设置 映射 老的配置中心ID
export const newKey2OldId = new Map([
  ['head-up-verification', ['3', '4']],
  ['consecutive-verification',['1017390098660823042']],
  ['invoice-to-cost',['996642904355127298']],
  ['invoice-controls',['1027161632266518530']],
  ['expense-print',['2']],
  ['price-tax',['1118154566255673346','1118152238467284994']]
]);


